package main;

import fm.report.ReportMoney;
import fm.customer.AddCustomer;
import fm.customer.UpCustomer;
import fm.ex_warehouse.LookEx_ware;
import fm.ex_warehouse.OutWare;
import fm.ex_warehouse.UpdateOut;
import fm.supplier.AddSupplier;
import fm.supplier.UpSupplier;
import fm.trade.LookTrade;
import fm.trade.Select_trade;
import fm.trade.TradeAdd;
import fm.trade.Update;
import fm.type.LookType;
import fm.type.TypeAdd;
import fm.type.UpdateType;
import fm.warehousing.InStorage;
import fm.warehousing.Look;
import fm.report.Report_trade;
import fm.warehousing.UpdateIn;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/*
 * Created by JFormDesigner on Mon Jun 05 21:27:42 CST 2023
 */



/**
 * @author YangC
 */
public class MainFm extends JFrame {
    private static JDesktopPane desktopPane1 = null;
    public MainFm() {
        initComponents();
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }


    public static JDesktopPane getDesktopPane()
    {
        return desktopPane1;
    }

    private void Add(ActionEvent e) {
        // TODO add your code here
        TradeAdd tradeAdd = new TradeAdd();
        tradeAdd.setBounds(500,200,490,365);
        desktopPane1.add(tradeAdd,JLayeredPane.MODAL_LAYER);
    }

    private void Cancel(ActionEvent e) {
        // TODO add your code here
        System.exit(0);
    }

    private void Up(ActionEvent e) {
        // TODO add your code here
        Update update = new Update();
        update.setBounds(500,200,575,425);
        desktopPane1.add(update,JLayeredPane.MODAL_LAYER);
    }

    private void Look(ActionEvent e) {
        // TODO add your code here
        LookTrade lookTrade = new LookTrade();
        lookTrade.setBounds(480,200,590,385);
        desktopPane1.add(lookTrade,JLayeredPane.MODAL_LAYER);
    }

    private void SelectTrade(ActionEvent e) {
        // TODO add your code here
        Select_trade selectTrade = new Select_trade();
        selectTrade.setBounds(500,200,665,415);
        desktopPane1.add(selectTrade,JLayeredPane.MODAL_LAYER);
    }

    private void LookType(ActionEvent e) {
        // TODO add your code here
        LookType lookType = new LookType();
        lookType.setBounds(500,200,475,405);
        desktopPane1.add(lookType,JLayeredPane.MODAL_LAYER);
    }

    private void updates(ActionEvent e) {
        // TODO add your code here
        UpdateType update = new UpdateType();
        update.setBounds(500,200,490,410);
        desktopPane1.add(update,JLayeredPane.MODAL_LAYER);

    }

    private void typeAdd(ActionEvent e) {
        // TODO add your code here
        TypeAdd typeAdd = new TypeAdd();
        typeAdd.setBounds(500,200,545,380);
        desktopPane1.add(typeAdd,JLayeredPane.MODAL_LAYER);
    }

    private void lookEnter(ActionEvent e) {
        // TODO add your code here
        Look look = new Look();
        look.setBounds(480,150,760,580);
        desktopPane1.add(look,JLayeredPane.MODAL_LAYER);

    }

    private void enter(ActionEvent e) {
        InStorage inStorage = new InStorage();
        inStorage.setBounds(480,150,645,585);
        desktopPane1.add(inStorage,JLayeredPane.MODAL_LAYER);
    }

    private void supplierAdd(ActionEvent e) {
        // TODO add your code here
        AddSupplier addSupplier = new AddSupplier();
        addSupplier.setBounds(500,200,575,410);
        desktopPane1.add(addSupplier,JLayeredPane.MODAL_LAYER);
    }

    private void supplierUp(ActionEvent e) {
        // TODO add your code here
        UpSupplier upSupplier = new UpSupplier();
        upSupplier.setBounds(500,200,530,410);
        desktopPane1.add(upSupplier,JLayeredPane.MODAL_LAYER);
    }

    private void addCus(ActionEvent e) {
        AddCustomer addCustomer = new AddCustomer();
        addCustomer.setBounds(500,200,490,400);
        desktopPane1.add(addCustomer,JLayeredPane.MODAL_LAYER);
    }

    private void upCus(ActionEvent e) {
        UpCustomer upCustomer = new UpCustomer();
        upCustomer.setBounds(500,200,590,400);
        desktopPane1.add(upCustomer,JLayeredPane.MODAL_LAYER);
    }

    private void outLook(ActionEvent e) {
        // TODO add your code here
        LookEx_ware lookExWare = new LookEx_ware();
        lookExWare.setBounds(480,150,660,515);
        desktopPane1.add(lookExWare,JLayeredPane.MODAL_LAYER);
    }

    private void out(ActionEvent e) {
        OutWare outWare = new OutWare();
        outWare.setBounds(480,150,690,610);
        desktopPane1.add(outWare,JLayeredPane.MODAL_LAYER);
    }

    private void report_trade(ActionEvent e) {
        Report_trade reportTrade = new Report_trade();
        reportTrade.setBounds(500,200,645, 505);
        desktopPane1.add(reportTrade,JLayeredPane.MODAL_LAYER);
    }

    private void money(ActionEvent e) {
        ReportMoney reportMoney = new ReportMoney();
        reportMoney.setBounds(450,200,645, 505);
        desktopPane1.add(reportMoney,JLayeredPane.MODAL_LAYER);
    }

    private void updateEX_ware(ActionEvent e) {
        UpdateOut updateOut = new UpdateOut();
        updateOut.setBounds(450,200,710,562);
        desktopPane1.add(updateOut,JLayeredPane.MODAL_LAYER);
    }

    private void updateIn(ActionEvent e) {
        UpdateIn updateIn = new UpdateIn();
        updateIn.setBounds(450,200,720,520);
        desktopPane1.add(updateIn,JLayeredPane.MODAL_LAYER);
    }

    private void desktopPane1ComponentResized(ComponentEvent e) {
        int width = desktopPane1.getWidth();
        int height = desktopPane1.getHeight();

        if (width != 0 && height != 0) {
            backLabel.setBounds(0, 0, width, height);
            ImageIcon icon = new ImageIcon(getClass().getResource("/ref/back.png"));
            icon.setImage(icon.getImage().getScaledInstance(width, height, Image.SCALE_DEFAULT));
            backLabel.setIcon(icon);
            backLabel.setOpaque(true);
        }
    }


    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents  @formatter:off
        menuBar1 = new JMenuBar();
        menu1 = new JMenu();
        LookMenuItem = new JMenuItem();
        SelectTradeMenuItem = new JMenuItem();
        AddMenuItem = new JMenuItem();
        UpMenuItem = new JMenuItem();
        menu = new JMenu();
        supplierAddMenuItem = new JMenuItem();
        supplierUpMenuItem = new JMenuItem();
        menu6 = new JMenu();
        addCusMenuItem = new JMenuItem();
        upCusMenuItem = new JMenuItem();
        menu2 = new JMenu();
        LookTypeMenuItem = new JMenuItem();
        updatesMenuItem = new JMenuItem();
        typeAddMenuItem = new JMenuItem();
        menu3 = new JMenu();
        enterMenuItem = new JMenuItem();
        updateInMenuItem = new JMenuItem();
        lookEnterMenuItem = new JMenuItem();
        menu4 = new JMenu();
        outMenuItem = new JMenuItem();
        updateEX_wareMenuItem = new JMenuItem();
        outLookMenuItem = new JMenuItem();
        menu5 = new JMenu();
        moneyMenuItem = new JMenuItem();
        report_tradeMenuItem = new JMenuItem();
        CancelMenuItem = new JMenuItem();
        toolBar1 = new JToolBar();
        lookEnterButton = new JButton();
        outLookButton = new JButton();
        enterButton = new JButton();
        outButton = new JButton();
        desktopPane1 = new JDesktopPane();
        backLabel = new JLabel();

        //======== this ========
        setTitle("\u6b22\u8fce\u4f7f\u7528sunny\u5e93\u5b58\u7ba1\u7406\u7cfb\u7edf\uff01");
        setIconImage(new ImageIcon(getClass().getResource("/ref/img_2.png")).getImage());
        var contentPane = getContentPane();
        contentPane.setLayout(new BorderLayout());

        //======== menuBar1 ========
        {

            //======== menu1 ========
            {
                menu1.setText("\u5546\u54c1\u7ba1\u7406");

                //---- LookMenuItem ----
                LookMenuItem.setText("\u67e5\u770b\u5546\u54c1");
                LookMenuItem.addActionListener(e -> Look(e));
                menu1.add(LookMenuItem);

                //---- SelectTradeMenuItem ----
                SelectTradeMenuItem.setText("\u67e5\u8be2\u5546\u54c1");
                SelectTradeMenuItem.addActionListener(e -> SelectTrade(e));
                menu1.add(SelectTradeMenuItem);

                //---- AddMenuItem ----
                AddMenuItem.setText("\u6dfb\u52a0\u5546\u54c1");
                AddMenuItem.addActionListener(e -> Add(e));
                menu1.add(AddMenuItem);

                //---- UpMenuItem ----
                UpMenuItem.setText("\u4fee\u6539\u4e0e\u5220\u9664");
                UpMenuItem.addActionListener(e -> Up(e));
                menu1.add(UpMenuItem);
            }
            menuBar1.add(menu1);

            //======== menu ========
            {
                menu.setText("\u4f9b\u5e94\u5546\u7ba1\u7406");

                //---- supplierAddMenuItem ----
                supplierAddMenuItem.setText("\u6dfb\u52a0\u4f9b\u5e94\u5546");
                supplierAddMenuItem.addActionListener(e -> supplierAdd(e));
                menu.add(supplierAddMenuItem);

                //---- supplierUpMenuItem ----
                supplierUpMenuItem.setText("\u5220\u9664\u6216\u4fee\u6539");
                supplierUpMenuItem.addActionListener(e -> supplierUp(e));
                menu.add(supplierUpMenuItem);
            }
            menuBar1.add(menu);

            //======== menu6 ========
            {
                menu6.setText("\u5ba2\u6237\u7ba1\u7406");

                //---- addCusMenuItem ----
                addCusMenuItem.setText("\u6dfb\u52a0\u5ba2\u6237");
                addCusMenuItem.addActionListener(e -> addCus(e));
                menu6.add(addCusMenuItem);

                //---- upCusMenuItem ----
                upCusMenuItem.setText("\u4fee\u6539\u6216\u5220\u9664");
                upCusMenuItem.addActionListener(e -> upCus(e));
                menu6.add(upCusMenuItem);
            }
            menuBar1.add(menu6);

            //======== menu2 ========
            {
                menu2.setText("\u5546\u54c1\u7c7b\u522b\u7ba1\u7406");

                //---- LookTypeMenuItem ----
                LookTypeMenuItem.setText("\u67e5\u770b\u5546\u54c1\u7c7b\u522b");
                LookTypeMenuItem.addActionListener(e -> LookType(e));
                menu2.add(LookTypeMenuItem);

                //---- updatesMenuItem ----
                updatesMenuItem.setText("\u4fee\u6539\u4e0e\u5220\u9664");
                updatesMenuItem.addActionListener(e -> updates(e));
                menu2.add(updatesMenuItem);

                //---- typeAddMenuItem ----
                typeAddMenuItem.setText("\u7c7b\u522b\u6dfb\u52a0");
                typeAddMenuItem.addActionListener(e -> typeAdd(e));
                menu2.add(typeAddMenuItem);
            }
            menuBar1.add(menu2);

            //======== menu3 ========
            {
                menu3.setText("\u5165\u5e93\u7ba1\u7406");

                //---- enterMenuItem ----
                enterMenuItem.setText("\u5165\u5e93");
                enterMenuItem.addActionListener(e -> enter(e));
                menu3.add(enterMenuItem);

                //---- updateInMenuItem ----
                updateInMenuItem.setText("\u4fee\u6539\u4e0e\u5220\u9664");
                updateInMenuItem.addActionListener(e -> updateIn(e));
                menu3.add(updateInMenuItem);

                //---- lookEnterMenuItem ----
                lookEnterMenuItem.setText("\u5165\u5e93\u6e05\u5355");
                lookEnterMenuItem.addActionListener(e -> lookEnter(e));
                menu3.add(lookEnterMenuItem);
            }
            menuBar1.add(menu3);

            //======== menu4 ========
            {
                menu4.setText("\u51fa\u5e93\u7ba1\u7406");

                //---- outMenuItem ----
                outMenuItem.setText("\u51fa\u5e93");
                outMenuItem.addActionListener(e -> out(e));
                menu4.add(outMenuItem);

                //---- updateEX_wareMenuItem ----
                updateEX_wareMenuItem.setText("\u4fee\u6539\u4e0e\u5220\u9664");
                updateEX_wareMenuItem.addActionListener(e -> updateEX_ware(e));
                menu4.add(updateEX_wareMenuItem);

                //---- outLookMenuItem ----
                outLookMenuItem.setText("\u51fa\u5e93\u6e05\u5355");
                outLookMenuItem.addActionListener(e -> outLook(e));
                menu4.add(outLookMenuItem);
            }
            menuBar1.add(menu4);

            //======== menu5 ========
            {
                menu5.setText("\u62a5\u8868");

                //---- moneyMenuItem ----
                moneyMenuItem.setText("\u8d22\u52a1\u62a5\u8868");
                moneyMenuItem.addActionListener(e -> money(e));
                menu5.add(moneyMenuItem);

                //---- report_tradeMenuItem ----
                report_tradeMenuItem.setText("\u5e93\u5b58\u62a5\u8868");
                report_tradeMenuItem.addActionListener(e -> report_trade(e));
                menu5.add(report_tradeMenuItem);
            }
            menuBar1.add(menu5);

            //---- CancelMenuItem ----
            CancelMenuItem.setText("\u9000\u51fa");
            CancelMenuItem.setMaximumSize(new Dimension(55, 327));
            CancelMenuItem.addActionListener(e -> Cancel(e));
            menuBar1.add(CancelMenuItem);
        }
        setJMenuBar(menuBar1);

        //======== toolBar1 ========
        {
            toolBar1.setFloatable(false);

            //---- lookEnterButton ----
            lookEnterButton.setText("\u5165\u5e93\u6e05\u5355");
            lookEnterButton.addActionListener(e -> lookEnter(e));
            toolBar1.add(lookEnterButton);

            //---- outLookButton ----
            outLookButton.setText("\u51fa\u5e93\u6e05\u5355");
            outLookButton.addActionListener(e -> outLook(e));
            toolBar1.add(outLookButton);

            //---- enterButton ----
            enterButton.setText("\u5165\u5e93");
            enterButton.addActionListener(e -> enter(e));
            toolBar1.add(enterButton);

            //---- outButton ----
            outButton.setText("\u51fa\u5e93");
            outButton.addActionListener(e -> out(e));
            toolBar1.add(outButton);
        }
        contentPane.add(toolBar1, BorderLayout.NORTH);

        //======== desktopPane1 ========
        {
            desktopPane1.setForeground(Color.cyan);
            desktopPane1.addComponentListener(new ComponentAdapter() {
                @Override
                public void componentResized(ComponentEvent e) {
                    desktopPane1ComponentResized(e);
                }
            });
            desktopPane1.add(backLabel, JLayeredPane.DEFAULT_LAYER);
            backLabel.setBounds(395, 175, 180, 175);
        }
        contentPane.add(desktopPane1, BorderLayout.CENTER);
        setSize(805, 520);
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents  @formatter:on
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables  @formatter:off
    private JMenuBar menuBar1;
    private JMenu menu1;
    private JMenuItem LookMenuItem;
    private JMenuItem SelectTradeMenuItem;
    private JMenuItem AddMenuItem;
    private JMenuItem UpMenuItem;
    private JMenu menu;
    private JMenuItem supplierAddMenuItem;
    private JMenuItem supplierUpMenuItem;
    private JMenu menu6;
    private JMenuItem addCusMenuItem;
    private JMenuItem upCusMenuItem;
    private JMenu menu2;
    private JMenuItem LookTypeMenuItem;
    private JMenuItem updatesMenuItem;
    private JMenuItem typeAddMenuItem;
    private JMenu menu3;
    private JMenuItem enterMenuItem;
    private JMenuItem updateInMenuItem;
    private JMenuItem lookEnterMenuItem;
    private JMenu menu4;
    private JMenuItem outMenuItem;
    private JMenuItem updateEX_wareMenuItem;
    private JMenuItem outLookMenuItem;
    private JMenu menu5;
    private JMenuItem moneyMenuItem;
    private JMenuItem report_tradeMenuItem;
    private JMenuItem CancelMenuItem;
    private JToolBar toolBar1;
    private JButton lookEnterButton;
    private JButton outLookButton;
    private JButton enterButton;
    private JButton outButton;
    private JLabel backLabel;
    // JFormDesigner - End of variables declaration  //GEN-END:variables  @formatter:on
}
